﻿namespace Shell
{
	using System;
	using System.Threading;

	internal class Program
	{
		private static decimal seconds = 1;

		private static void Main()
		{
			Console.WriteLine("Menu:");
			Console.WriteLine("1) Choice 1");
			Console.WriteLine("2) Choice 2");
			Console.WriteLine("3) Choice 3");
			Console.ForegroundColor = ConsoleColor.DarkGray;

			while (true)
			{
				if (Console.KeyAvailable)
				{
					var c = Console.ReadKey(true);
					Method(false, c.KeyChar);
					break;
				}

				Thread.Sleep(1000);

				Console.CursorTop = 5;
				Console.WriteLine("[Time] = {0}", seconds);

				if (seconds++ < 10)
				{
					continue;
				}

				Method(true, '2');
				break;
			}
		}

		private static void Method(bool timeout, char chr)
		{
			var message = "Key pressed: {0}";

			if (timeout)
			{
				message = "Autoselected: {0}";
			}

			Console.WriteLine();
			Console.WriteLine(message, chr);
		}
	}
}